package net.hxz.commons.global;

import java.math.BigDecimal;


public class Global {
	/**
	 * session中的session name
	 */
	public static final String SESSION_USER = "frontUser";
	/**
	 * session中的session name
	 */
	public static final String SESSION_SUPPLIER = "supplier";
	/**
	 * 后台root用户session中的session name
	 */
	public static final String SESSION_ROOT = "root";
	/**
	 * cookie/session的存活时间 ，以秒为单位，当然tomcat重启，session销毁
	 */
	public static final int MAX_AGE = 7*24*60*60;
	
	public static final String NULL_USER = ""; 
	
	public static final long NULL_ID = 0L;                //无效ID
    public static final int NO = 0;
    public static final int YES = 1;

    public static final int PAGE_SIZE = 12;//分页中每页大小

    /**
     * 用户激活标记
     */
    public static final int USER_ENABLE_NO = 0; //未激活
    public static final int USER_ENABLE_YES = 1; //激活
    /**
     * 用户类型标记
     */
    public static final int USERTYPE_ISADMIN_NO = 0; //普通会员；
    public static final int USERTYPE_ISADMIN_YES = 1; //系统管理员；

    /**
     * 用户登录的目的地
     */
    public static final int TARGET_SYSTEM = 0; //系统管理后台
    public static final int TARGET_MEMBER = 1; //会员专区

    public static final int ALL = -1; //代表所有

    public static final String VISITOR_ID = "-1";//代表游客用户ID


    public static final long COLUMNID_ROOT = 1;//后台管理
    public static final long INFO_SORT_ROOT = 30;//信息分类

    public static final String FRONTEND_JSP_BASE_PATH = "frontEnd/";
    public static final String BACKEND_JSP_BASE_PATH = "backEnd/";
    public static final String RETURNURL = "returnUrl";

    public static final int PROPOTION_CONFIRM = 100;

    /**
     * 身份证正则表达式
     */
    public static final String REG_ID = "(^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$)|(^(\\d{6})(18|19|20)?(\\d{2})((0[1-9])|(1[0-2]))((0[1-9])|([1|2][0-9])|(3[0-1]))(\\d{3})(\\d|[Xx]){1}$)";

    /**
     * 手机正则表达式
     */
    public static final String PHONE_REGEX = "(^1[3|4|5|8]\\d{9}$)";
    public static final int APPLY_MONEY_FAIL = -1;

    //IMPORT包正则表达式
    public static final String IMPORT_REGEX = "(^(([a-zA-Z])+\\.)+\\*$)";

    /**
     * 文件图标
     */
    public static final class fileSuffix {
        /**
         * 可以预览 的正则表达式
         */
        public static final String REGEX_DOC = "(^.*\\.(doc|docx|rtf|wpt|wps|xls|xlsx|et|ett|ppt|pptx|dps|dpt|txt|jpg|png|ico|bmp|gif|tif|pdf)$)";
    }
    
    /**
     * 默认邮费15元
     */
    public static final int POSTAGE = 15;
    
    /**
     * 邮费
     * @author LYM
     */
    public static enum Postage {
    	
    	/**
    	 * 枚举常量，(地区ID, 邮费)
    	 */
    	新疆(3174, Global.POSTAGE),
    	西藏(2794, Global.POSTAGE),
    	甘肃(2993, Global.POSTAGE),
    	青海(3094, Global.POSTAGE),
    	宁夏(3146, Global.POSTAGE),
    	内蒙古(352, Global.POSTAGE),
    	黑龙江(651, Global.POSTAGE),
    	辽宁(466, Global.POSTAGE),
    	吉林(581, Global.POSTAGE);
    	
    	/**
    	 * 地区ID
    	 */
        private int areaId;
        /**
         * 邮费
         */
        private int cost;

        private Postage(int areaId, int cost) {
            this.areaId = areaId;
            this.cost = cost;
        }

        /**
         * 获取地区所需邮费
         * @param areaId 地区ID
         * @return 如无其地区，返回默认邮费
         */
        public static int getCost(int areaId) {
            for (Postage p : Postage.values()) {
                if (p.areaId == areaId) {
                    return p.cost;
                }
            }
            return Global.POSTAGE;
        }
    	
    }
    
    /**
     * 订单状态
     * @author Isaac
     */
    public static final class orderStatus{
    	/**
    	 * 未付款
    	 */
    	public static final int NOT_PAY = 1;
    	
    	/**
    	 * 未发货
    	 */
    	public static final int NOT_SEND = 2;
    	
    	/**
    	 * 已发货
    	 */
    	public static final int SENDED = 3;
    	
    	/**
    	 * 已收货
    	 */
    	public static final int RECEICED = 4;
    	
    	/**
    	 * 已退货
    	 */
    	public static final int BACK = 5;
    }
    
    /**
     * 货物的钱
     * @author Isaac
     */
    public static final class GoodsMoney{
    	public static BigDecimal GOODS1 = new BigDecimal(1);
    	public static BigDecimal GOODS2 = new BigDecimal(2);
    }
}

